﻿
namespace HSS.Interlink.UI
{
	/// <summary>
	/// Default implementation of <see cref="IUploadConfiguration"/>.
	/// </summary>
	public sealed class UploadConfiguration : IUploadConfiguration
	{
		/// <summary>
		/// Default Constructore
		/// </summary>
		public UploadConfiguration()
		{

		}

		/// <summary>
		/// Gets a new <see cref="UploadConfiguration"/> with it's values populated from an instance of the <see cref="UploadControl"/>.
		/// </summary>
		public static IUploadConfiguration Default
		{
			get
			{
				var ctl = new UploadControl();
				var config = new UploadConfiguration();

				config.AllowFileOverwrite = ctl.AllowFileOverwrite;
				config.AllowMultiSelect = ctl.AllowMultiSelect;
				config.AllowNewUpload = ctl.AllowNewUpload;
				config.AutoUpload = ctl.AutoUpload;
				config.ClientConfig = ctl.ClientConfig;
				config.ClientType = ctl.ClientType;
				config.Comment = ctl.Comment;
				config.ExcludeFileExtension = ctl.ExcludeFileExtension;
				config.Filters = ctl.Filters;
				config.MaximumConcurrency = ctl.MaximumConcurrency;
				config.MaximumFileSize = ctl.MaximumFileSize;
				config.NoFilesText = ctl.NoFilesText;
				config.ServiceUri = ctl.ServiceUri;
				config.Title = ctl.Title;
				config.UploadFileDataTemplate = ctl.UploadFileDataTemplate;
				config.UploadFileType = ctl.UploadFileType;

				return config;
			}
		}

		#region IUploadConfiguration Members

		/// <summary>
		/// Gets or sets whether or not to overwrite existing files
		/// </summary>
		public bool AllowFileOverwrite
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets whether or not the user can select multiple files.
		/// </summary>
		public bool AllowMultiSelect
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets whether or not once the first upload process completes, if the User can initiate a new Upload.
		/// </summary>
		public bool AllowNewUpload
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets whether or not to begin uploading immediately after file selection.
		/// </summary>
		public bool AutoUpload
		{
			get;
			set;
		}
		/// <summary>
		/// The configuration string to provide to the configurated IUploadClient client during intialization.
		/// </summary>
		public string ClientConfig
		{
			get;
			set;
		}
		/// <summary>
		/// A string defining the Type of the IUploadClient that will process the upload for a single file.
		/// </summary>
		public string ClientType
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the comment to display in the header area.
		/// </summary>
		public string Comment
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the pipe delimited list of file extensions that are prohibited. Example: .exe|.mdb
		/// </summary>
		public string ExcludeFileExtension
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets a pipe delimeted string of allowed file extensions that can be uploaded.
		/// </summary>
		public string Filters
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the maximum number of concurrent files that can be uploaded at a time.
		/// </summary>
		public int MaximumConcurrency
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the maximum size, in bytes, of any one file that can be uploaded.
		/// </summary>
		public int MaximumFileSize
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the text to be displayed when there are no files selected for upload.
		/// </summary>
		public string NoFilesText
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the uri (absolute or relative) to the upload service to receive the file(s). For OOB must be the absolute Uri.
		/// </summary>
		public string ServiceUri
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the title to display in the header area.
		/// </summary>
		public string Title
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the Uri of a <see cref="System.Windows.DataTemplate"/> resource to load, that supports the Type defined in the <see cref="UploadFileType"/> property.
		/// </summary>
		public string UploadFileDataTemplate
		{
			get;
			set;
		}
		/// <summary>
		/// Gets or sets the fully qualified name of the Type of the model that contains an individual file for upload and must be or derive from HSS.Interlink.UI.UploadFile.
		/// </summary>
		public string UploadFileType
		{
			get;
			set;
		}
		#endregion
	}
}
